﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../../Comm/Gener.js"></script>
    <script src="DDLBar.js" type="text/javascript"></script>
    <script src="../../CCFlowEnum.js" type="text/javascript"></script>
    <script src="../../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <script src="../../../Scripts/vue.js"></script>
</head>
<body>
    <div id="App">
        <div id="bar"> </div>

        <div id="AdminModel">
            <fieldset v-show="adminModel===1">
                <legend>设置(超级管理员)</legend>
                <ul>
                    <li><a href="#" @click="OpenNew()"> 设置/更改部门</a></li>
                    <li><a href="#" @click="OpenNewOrg()"> 设置/更改本组织部门</a></li>
                    <!-- <li><a href="javascript:OpenOld()">设置/更改部门(旧版本)</a></li>-->
                    <li>该部门下所有的人员都可以处理该节点的工作。</li>
                </ul>
            </fieldset>
        </div>
        <div id="OrgModel">
            <fieldset v-show="orgModel===1">
                <legend>设置（组织管理员）</legend>
                <ul>
                    <li v-show="isShow"><a href="#" @click="BindDeptTreeGroup()">设置集团部门</a> </li>
                    <li v-show="isShow"><a href="#" @click="BindDeptTreeGroupLazy()">设置集团部门(懒加载)</a> </li>
                    <li><a href="#" @click="BindDeptTree()">设置本组织部门</a> </li>
                    <li><a href="#" @click="BindDeptTreeLazy()">设置本组织部门(懒加载)</a> </li>
                </ul>
            </fieldset>
        </div>

        <fieldset>
            <legend>已经选择的部门</legend>
            <div id="dept">
                <ul>
                    <li v-show="depts.length===0">未设置</li>
                    <template v-for="dept in depts">
                        <li v-if="dept.FK_DeptText!=undefined">{{dept.FK_DeptText}}</li>
                    </template>
                </ul>

            </div>
        </fieldset>

        <fieldset>
            <legend id="help">帮助</legend>
            <ul>
                <li>节点绑定部门就是该节点下绑定部门里面的所有人员都可以接受该工作.</li>
            </ul>
        </fieldset>
    </div>
    <script type="text/javascript">
        var Baseinfo = new Vue({
            el: '#App',
            data: {
                adminModel: 1,
                orgModel: 0,
                depts: [],
                webuser: null,
                deliverWay: SelectorModel.Dept,
                isShow:true
            },
            methods: {
                OpenNew: function () {

                    var nodeID = GetQueryString("FK_Node");
                    var url = "../../../Comm/RefFunc/Branches.htm?EnName=BP.WF.Template.NodeSheet&Dot2DotEnsName=BP.WF.Template.NodeDepts&Dot2DotEnName=BP.WF.Template.NodeDept&AttrOfOneInMM=FK_Node&AttrOfMInMM=FK_Dept&EnsOfM=BP.Port.Depts&DefaultGroupAttrKey=";

                    url +='&NodeID=' + nodeID + '&PKVal=' + nodeID;
                    var H = document.documentElement.clientHeight - 30;
                    OpenEasyUiDialogExtCloseFunc(url, '绑定部门', 500, H, function () {
                        Baseinfo.depts = getDepts();
                    });
                },
                OpenNewOrg: function () {
                    var webUser = new WebUser();
                    if (webUser.CCBPMRunModel != 0)
                     rootNo = webUser.OrgNo;
                    var nodeID = GetQueryString("FK_Node");
                    var url = "../../../Comm/RefFunc/Branches.htm?EnName=BP.WF.Template.NodeSheet&Dot2DotEnsName=BP.WF.Template.NodeDepts&Dot2DotEnName=BP.WF.Template.NodeDept&AttrOfOneInMM=FK_Node&AttrOfMInMM=FK_Dept&EnsOfM=BP.Port.Depts&DefaultGroupAttrKey=";

                    url +=  '&NodeID=' + nodeID + '&PKVal=' + nodeID + '&RootNo=' + rootNo;
                    var H = document.documentElement.clientHeight - 30;
                    OpenEasyUiDialogExtCloseFunc(url, '绑定部门', 500, H, function () {
                        Baseinfo.depts = getDepts();
                    });
                },
                BindDeptTree: function () {
                    var nodeID = GetQueryString("FK_Node");
                    var rootNo = 0;
                    var webUser = new WebUser();
                    if (webUser.CCBPMRunModel != 0)
                        rootNo = webUser.OrgNo;

                    var url = "../../../Comm/RefFunc/Branches.htm?EnName=BP.WF.Template.NodeSheet&Dot2DotEnsName=BP.WF.Template.NodeDepts&Dot2DotEnName=BP.WF.Template.NodeDept&AttrOfOneInMM=FK_Node&AttrOfMInMM=FK_Dept&EnsOfM=BP.WF.Port.Depts&DefaultGroupAttrKey=&RootNo=" + rootNo + "&NodeID=" + nodeID + "&PKVal=" + nodeID;

                    OpenEasyUiDialogExtCloseFunc(url, '绑定部门', 500, 600, function () {
                        Baseinfo.depts = getDepts();
                    });

                },
                BindDeptTreeGroup: function () {
                    var nodeID = GetQueryString("FK_Node");
                    var rootNo = "14819";

                    var url = "../../../Comm/RefFunc/Branches.htm?EnName=BP.WF.Template.NodeSheet&Dot2DotEnsName=BP.WF.Template.NodeDepts&Dot2DotEnName=BP.WF.Template.NodeDept&AttrOfOneInMM=FK_Node&AttrOfMInMM=FK_Dept&EnsOfM=BP.WF.Port.Depts&DefaultGroupAttrKey=&RootNo=" + rootNo + "&NodeID=" + nodeID + "&PKVal=" + nodeID;

                    OpenEasyUiDialogExtCloseFunc(url, '绑定部门', 500, 600, function () {
                        Baseinfo.depts = getDepts();
                    });
                },
                 BindDeptTreeLazy: function () {
                    var nodeID = GetQueryString("FK_Node");
                    var rootNo = 0;
                    var webUser = new WebUser();
                    if (webUser.CCBPMRunModel != 0)
                        rootNo = webUser.OrgNo;

                    var url = "../../../Comm/RefFunc/BranchesLazy.htm?EnName=BP.WF.Template.NodeSheet&Dot2DotEnsName=BP.WF.Template.NodeDepts&Dot2DotEnName=BP.WF.Template.NodeDept&AttrOfOneInMM=FK_Node&AttrOfMInMM=FK_Dept&EnsOfM=BP.WF.Port.Depts&DefaultGroupAttrKey=&RootNo=" + rootNo + "&NodeID=" + nodeID + "&PKVal=" + nodeID;

                    OpenEasyUiDialogExtCloseFunc(url, '绑定部门', 500, 600, function () {
                        Baseinfo.depts = getDepts();
                    });

                },
                BindDeptTreeGroupLazy: function () {
                    var nodeID = GetQueryString("FK_Node");
                    var rootNo = "14819";

                    var url = "../../../Comm/RefFunc/BranchesLazy.htm?EnName=BP.WF.Template.NodeSheet&Dot2DotEnsName=BP.WF.Template.NodeDepts&Dot2DotEnName=BP.WF.Template.NodeDept&AttrOfOneInMM=FK_Node&AttrOfMInMM=FK_Dept&EnsOfM=BP.WF.Port.Depts&DefaultGroupAttrKey=&RootNo=" + rootNo + "&NodeID=" + nodeID + "&PKVal=" + nodeID;

                    OpenEasyUiDialogExtCloseFunc(url, '绑定部门', 500, 600, function () {
                        Baseinfo.depts = getDepts();
                    });
                }
            },
            created() {
                InitBar(this.deliverWay);
                

                //根据用户的信息，判断是否启用那个设置工具。
                this.webuser = new WebUser();
                this.adminModel = this.webuser.No == "admin" ? 1 : 0;
                this.orgModel = this.webuser.No == "admin" ? 0 : 1;
                var orgNo = this.webuser.No == "admin" ? null : this.webuser.OrgNo
                this.depts = getDepts(orgNo);
                this.isShow = this.webuser.CCBPMRunModel == 2 ? false : true;

            }
        });
        function OpenNodDeptGroup(orgNo) {
            var url = "NodeDeptGroup.htm?OrgNo=" + orgNo + "&FK_Node=" + GetQueryString("FK_Node");
            var H = document.documentElement.clientHeight - 30;
            OpenEasyUiDialogExtCloseFunc(url, '绑定部门', 500, H, function () {
                Baseinfo.depts = getDepts();
            });
        }

        //保存
        function Save() {
            
            var nodeID = GetQueryString("FK_Node");
            var node = new Entity("BP.WF.Template.Selector", nodeID);
            node.SelectorModel = Baseinfo.deliverWay;
            node.Update();

            var node = new Entity("BP.WF.Node", nodeID);
            node.DeliveryWay = 4;
            node.Update();

            alert("保存成功.");
        }
    </script>
</body>

</html>
